package com.springapp.fed.domain.service;

import com.restfb.FacebookClient;
import com.restfb.Parameter;
import com.springapp.fed.domain.dao.FacebookProfilerDao;
import com.springapp.fed.domain.model.FacebookProfiles;
import com.springapp.fed.domain.model.FacebookUserJson;
import com.springapp.fed.domain.model.UserData;
import org.drools.lang.Location;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.facebook.api.Facebook;
import org.springframework.social.facebook.api.FacebookProfile;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import org.springframework.util.MultiValueMap;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: WENKY
 * Date: 10/31/13
 * Time: 9:36 PM
 * To change this template use File | Settings | File Templates.
 */
@Service
public class FraudDetectionService {
    @Autowired
    FacebookClient facebookClient;
    @Autowired
    FacebookProfilerDao facebookProfilerDao;
    @Autowired
    Facebook facebook;
    public void processFraudDetection(Model  model){
    //   Map<String,String> userData =(Map<String,String>)model.asMap().get("userdata");
        Map<String,List<String>> userdata= (HashMap<String,List<String>>) model.asMap().get("userdata");
        FacebookUserJson facebookUserJson=facebook.fetchObject("100003837644339", FacebookUserJson.class  ,
                CollectionUtils.toMultiValueMap(userdata));
        facebook.userOperations().search("");
/*Uses restfb
        FacebookProfiles facebookProfiles=facebookClient.fetchObjects(
                Arrays.asList("user"),
                FacebookProfiles.class, Parameter.with("first_name",userData.getFirstName()));
        System.out.println(facebookProfiles.getUser());
*/
    }
}
